package org.example.service.impl;

import org.example.mapper.HairTypeMapper;
import org.example.model.HairType;
import org.example.model.HairTypeExample;
import org.example.service.HairTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class HairTypeServiceImpl implements HairTypeService {

    @Autowired
    private HairTypeMapper hairTypeMapper;

    @Override
    public List<HairType> listAll() {
        return hairTypeMapper.selectByExample(new HairTypeExample());
    }

    @Override
    public int create(HairType hairType) {
        hairType.setId(null);
        return hairTypeMapper.insert(hairType);
    }

    @Override
    public int update(Long id,HairType hairType) {
        hairType.setId(id);
        return hairTypeMapper.updateByPrimaryKeySelective(hairType);
    }
}
